package acm.usa2005.gnewyork;

import java.math.BigInteger;
import java.util.Scanner;

/*
 * p2149
 * Greater New York 2005
 */

public class p2149 {

	static int N;
	static String s1, s2;
	static BigInteger i1, i2, i3;

	public static void main(String[] args) {

		Scanner scanner = new Scanner(System.in);
		N = scanner.nextInt();
		for (int i=1;i<=N;++i) {
			s1 = scanner.next();
			s2 = scanner.next();
			i1 = new BigInteger(s1, 2);
			i2 = new BigInteger(s2, 2);
			i3 = i1.add(i2);
			System.out.println(i + " " + i3.toString(2));
		}

	}

}
